//
//  EFAPjtDetailTCell.m
//  efairy
//
//  Created by XiangDongMBP on 2017/8/14.
//  Copyright © 2017年 East. All rights reserved.
//

#import "EFAPjtDetailTCell.h"
#import "EFAModel.h"

@implementation EFAPjtDetailTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation EFAPjtDetailTCell (PjtDetailInfo)
- (void)configViewWithPjtListItem:(EFAPjtListItem *)item indexPath:(NSIndexPath *)indexPath {
//    NSArray *titleArray = @[@"项目名称", @"平台维护费", @"项目负责人", @"项目负责人手机号", @"项目地址", @"项目备注"];
//    NSArray *valueArray = @[item.efairyproject_name ? item.efairyproject_name : @"",
//                            @(item.efairyproject_fee_type),
//                            item.efairyproject_user_name ? item.efairyproject_user_name : @"",
//                            item.efairyproject_user_phonenumber ? item.efairyproject_user_phonenumber : @"",
//                            item.efairyproject_address ? item.efairyproject_address : @"",
//                            item.efairyproject_description ? item.efairyproject_description : @""];
    
    NSArray *titleArray = @[@"项目名称", @"项目负责人", @"项目负责人手机号", @"项目地址", @"项目备注"];
    NSArray *valueArray = @[item.efairyproject_name ? item.efairyproject_name : @"",
                            item.efairyproject_user_name ? item.efairyproject_user_name : @"",
                            item.efairyproject_user_phonenumber ? item.efairyproject_user_phonenumber : @"",
                            item.efairyproject_address ? item.efairyproject_address : @"",
                            item.efairyproject_description ? item.efairyproject_description : @""];
    
    if (indexPath.row < titleArray.count) {
        self.titleLabel.text = titleArray[indexPath.row];
        if (indexPath.row < valueArray.count) {
            self.valueLabel.text = [NSString stringWithFormat:@"%@", valueArray[indexPath.row]];
        }
    }
    self.arrowWidthConstraint.constant = 0;
}
@end

@implementation EFAPjtDetailTCell (PjtDetailUserInfo)
- (void)configViewWithUserItem:(EFAPjtDetUserItem *)item {
    self.titleLabel.text = item.efairyuser_nickname;
    self.valueLabel.text = item.efairyuser_phonenumber;
    self.arrowWidthConstraint.constant = 20;
}
- (void)configViewWithGMItem:(EFAPjtDetUserItem *)item hidePhone:(BOOL)hide {
    self.titleLabel.text = item.efairyuser_nickname;
    NSString *phoneNum = item.efairyuser_phonenumber;
    if (hide && phoneNum.length == 11) {
        phoneNum = [phoneNum stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"^_^"];
    }
    self.valueLabel.text = phoneNum;
    self.arrowWidthConstraint.constant = 0;
}
@end
@implementation EFAPjtDetailTCell (PjtDetailDeviceInfo)
- (void)configViewWithDeviceItem:(EFADeviceListItem *)item {
    self.titleLabel.text = item.efairydevice_name;
    self.valueLabel.text = [NSString stringWithFormat:@"%ld", (long)item.efairydevice_id];
    self.arrowWidthConstraint.constant = 20;
}
@end


#pragma mark - 项目管理-设备列表
@implementation EFAPjtDetailTCell (PjtDeviceList)
- (void)configViewWithDeviceListItem:(EFADeviceListItem *)item {
    self.titleLabel.text = item.efairydevice_name;
    self.valueLabel.text = [NSString stringWithFormat:@"UUID:%@", item.efairydevice_uuid];
}
@end


